<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <input id="a" type="button" value="左上" >
    <input id="b" type="button" value="左下" >
    <input id="c" type="button" value="右上" >
    <input id="d" type="button" value="右下" >
    <input id="e" type="button" value="空心菱形" >
    <input id="f" type="button" value="实心菱形" >
    <script>
        var a = document.getElementById('a');
        a.onclick = function() {
            var num = parseInt(window.prompt("请输入一个值"));
            for (var i = 0; i < num; i++) {
                for (var j = 0; j < num; j++) {
                    if (i <= j) {
                        document.write("*   ");
                    }
                }
                document.write("<br>");
            }
        }
//        ---------------------------------------------------
        var b = document.getElementById('b');
        b.onclick = function() {
            var num = parseInt(window.prompt("请输入一个值"));
            for (var i = 0; i < num; i++) {
                for (var j = 0; j < num; j++) {
                    if (i + j>num-1) {
                        document.write("*   ");
                    }else {
                        document.write("   ");
                    }
                }
                document.write("<br>");
            }
        }
//        ---------------------------------------------------
        var c = document.getElementById('c');
        c.onclick = function() {
            var num = parseInt(window.prompt("请输入一个值"));
            for (var i = 0; i < num; i++) {
                for (var j = 0; j < num; j++) {
                    if (i >= j) {
                        document.write("&nbsp;&nbsp;");
                    }else {
                        document.write("*   ");
                    }
                }
                document.write("<br>");
            }
        }
//        ----------------------------------------------------
        var d = document.getElementById('d');
        d.onclick = function() {
            var num = parseInt(window.prompt("请输入一个值"));
            for (var i = 0; i < num; i++) {
                for (var j = 0; j < num; j++) {
                    if (i + j<num-1) {
                        document.write("&nbsp; ");
                    }else {
                        document.write(" *");
                    }
                }
                document.write("<br>");
            }
        }
        //        ---------------------------------------------------
        var e = document.getElementById('e');
        e.onclick = function() {
            var n = parseInt(window.prompt("请输入一个值"));
            n = 2 * n - 1;
            var temp = parseInt(n / 2 + 1);
            for (var i = 0; i < n; i++) {
                for (var j = 1; j <= n; j++) {
                    if (temp <= i) {
                        if (j == (i - temp) + 2 || j == 2 * temp - i + parseInt(n / 2 - 1)) {
                            document.writeln("*");
                        }
                        else {
                            document.writeln("&nbsp;");
                        }
                    }
                    else {
                        if (j == temp - i || j == temp + i) {
                            document.writeln("*");
                        }
                        else {
                            document.writeln("&nbsp;");
                        }
                    }
                }
                document.writeln("<br/>");
            }
        }
        //        ---------------------------------------------------
        var f = document.getElementById('f');
        f.onclick = function() {
            var n = parseInt(window.prompt("请输入一个值"));
            n=2*n-1;
            var temp = parseInt(n / 2 + 1);
            for(var i=0;i<n;i++){
                for(var j=1;j<=n;j++){
                    if(temp<=i){
                        if(j>=(i-temp)+2&&j<=2*temp-i+parseInt(n/2-1)){
                            document.writeln("*");
                        }
                        else{
                            document.writeln("&nbsp;");
                        }
                    }
                    else{
                        if(j>=temp-i&&j<=temp+i){
                            document.writeln("*");
                        }
                        else{
                            document.writeln("&nbsp;");
                        }
                    }
                }
                document.writeln("<br/>");
            }
        }
    </script>
</body>
</html>